<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <router-view></router-view>
        <router-link to="/">进入页面一</router-link>
        <router-link to="/page2">进入页面二</router-link>
    </div>
    <script src="./js/vue.js"></script>
    <script src="./js/vue-router.js"></script>
    <script>
        const page1 = {
            template:  `
                <div>这是page1</div>
            `,
            beforeCreate() {
                
            },
            created() {
                
            },

            beforeMount() {
                
            },
            mounted() {
                
            },
            beforeDestroy() {
                console.log('page1销毁之前')
            },
            destroyed() {
                
            },
        }

        const page2 = {
            template:  `
                <div>这是page2</div>
            `,
            beforeCreate() {
                
            },
            created() {
                console.log('page2创建完成')
            },

            beforeMount() {
                console.log('page2渲染之前')
            },
            mounted() {
                console.log('page2渲染之后')
            },
            beforeDestroy() {
            },
            destroyed() {
                
            },

        }

        let router = new VueRouter({
            routes: [
                {
                    path: '/',
                    component: page1
                },
                {
                    path: '/page2',
                    component: page2
                }
            ]
        })

        new Vue({
            el: '#app',
            router
        })
    </script>
</body>
</html>